package com.jili;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jili.entity.User;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Arrays;
import java.util.List;

/**
 * ClassName: UtilDemo
 * Package com.jili
 * Description:
 *
 * @Author: 廖继礼
 * @Create: 2025/2/23
 * @Version: v1.0
 */
@SpringBootTest
public class UtilDemo {

    @Test
    public void test() throws JsonProcessingException {
        List<User> userList = Arrays.asList(new User(1L, 25, "廖继礼"),
                new User(2L, 25, "陈茵"),
                new User(3L, 23, "朱娇彩"));
        ObjectMapper objectMapper = new ObjectMapper();
        String json = objectMapper.writeValueAsString(userList);
        System.out.println("json = " + json);
    }
}
